
Partial Class Modules_Questionnaires_CategoryManager
    Inherits System.Web.UI.Page


    Protected Sub butInsert_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
        Dim txtName As TextBox
        Dim txtDesc As TextBox
        With gvCategories
            If .Rows.Count = 0 Then
                txtName = .Controls(0).Controls(0).FindControl("txtName")
                txtDesc = .Controls(0).Controls(0).FindControl("txtDesc")
            Else
                txtName = .FooterRow.FindControl("txtName")
                txtDesc = .FooterRow.FindControl("txtDesc")
                .ShowFooter = False
            End If
        End With
        DotNetPM.Business.Questionnaire.CategoryODS.CreateCategory(txtName.Text, txtDesc.Text)
        gvCategories.DataBind()
        lbutNew.Enabled = True
    End Sub

    Protected Sub butCancel_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
        With gvCategories
            If .Rows.Count = 0 Then
                Dim trEmpty As HtmlTableRow _
                = .Controls(0).Controls(0).FindControl("trEmpty")
                trEmpty.Visible = False
                Dim trEmptyMessage As HtmlTableRow _
                = .Controls(0).Controls(0).FindControl("trEmptyMessage")
                trEmptyMessage.Visible = True
            Else
                .ShowFooter = False
            End If
        End With
        lbutNew.Enabled = True
    End Sub


    Protected Sub lbutNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbutNew.Click
        With gvCategories
            .EditIndex = -1
            If .Rows.Count = 0 Then
                Dim trEmpty As HtmlTableRow _
                = .Controls(0).Controls(0).FindControl("trEmpty")
                trEmpty.Visible = True
                Dim trEmptyMessage As HtmlTableRow _
                = .Controls(0).Controls(0).FindControl("trEmptyMessage")
                trEmptyMessage.Visible = False
            Else
                .ShowFooter = True
            End If
        End With
        lbutNew.Enabled = False
    End Sub

    Protected Sub gvCategories_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvCategories.RowCommand
        gvCategories.ShowFooter = False
        lbutNew.Enabled = True
    End Sub
End Class
